<template>
	<view class="me">
		<!-- 编辑区域 -->
		<view class="edit eidt-title">
			<input type="text" placeholder="标题" v-model="editTitle" />
		</view>
		<lRichTextEditor value="" @change="GetChange">
		</lRichTextEditor>
	</view>
</template>
<script>
	import server from '@/util/http.js'
	export default {
		data() {
			return {
				editTitle: "",
				edier: ''
			}
		},
		onNavigationBarButtonTap(e) {
			if (e.index == 1) {
				let data = new Date();
				server({
					url: 'http://101.43.227.220:3004/topic/add',
					method: 'post',
					data: {
						id: 2,
						motif: this.editTitle,
						content: this.edier,
						creatTime: data
					},
					success: res => {
						console.log(res);

					}
				})
			} else {
				uni.switchTab({
					url: '../home/home'
				})
			}
		},
		methods: {
			GetChange(e) {
				console.log(e);
				this.edier = e;
			},
			// insertImg() {
			// 	uni.chooseImage({
			// 		count: 1,
			// 		success: res => {
			// 			this.imgPath = res.tempFilePaths;
			// 			uni.uploadFile({
			// 				fileType: "img",
			// 				url: 'http://101.43.227.220:3003/teacher/uploadPhoto',
			// 				filePath: this.imgPath[0],
			// 				name: 'file',
			// 				header: {
			// 					// 'Content-Type': "multipart/form-data",
			// 					'token': 'i8jeGBrEVKCvIya4S45LjpaVSBU2eW5SE06YQepjI'
			// 				},
			// 				success: res => {
			// 					let data = JSON.parse(res.data);
			// 					let imageUrl = data.data.filepath;
			// 					uni.setStorage({
			// 						key: 'photoUrl',
			// 						data: imageUrl
			// 					});
			// 				},
			// 				fail: e => {
			// 					console.log(e);
			// 				}
			// 			})
			// 		}
			// 	})

			// }
		}
	}
</script>

<style lang="scss">
	.me {
		position: fixed;
		width: 100%;
		padding: 30upx;
		box-sizing: border-box;
		overflow-y: auto;

		.edit-title {
			border-bottom: 1px solid rgba($color: #ccc, $alpha: 0.3);
		}

		// edit textarea
		.edit {
			width: 100%;
			box-sizing: border-box;
			background: #fff;
			padding-top: 20upx;
			padding-bottom: 20upx;

			textarea {
				width: 100%;
			}
		}

		// img icon
		.imgs-wrap {
			margin-top: 30upx;
			display: flex;
			flex-wrap: wrap;
			width: 100%;

			& .file,
			& .add-img {
				width: 32%;
				border: 1px solid #ccc;
				box-sizing: border-box;
				margin-top: 20upx;
				position: relative;
				height: 240upx;
				margin-left: 5upx;
				border-radius: 4upx;
			}

			& .file {
				position: relative;

				.del {
					position: absolute;
					width: 35rpx;
					height: 35rpx;
					background: #f56c6c;
					color: #fff;
					top: 0;
					text-align: center;
					right: 0;
					line-height: 35rpx;
					font-size: 30rpx;
					z-index: 100;
				}

				image {
					width: 100%;
					height: 100%;
				}
			}



			& .add-img {
				display: flex;
				align-items: center;
				justify-content: center;

				.icon {
					font-size: 80upx;
					color: #999;
				}
			}
		}
	}
</style>
